feat: also try to auth for config if server returns status 403 #12446
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes it so that the
registry-auth
unstable feature also attempts to make authorized requests to a registry'sconfig.json
(in sparse mode) if the server's response code is 403, not just 401.These status codes have very similar meanings and some 3rd-party registry providers (e.g. Artifactory) prefer to return 403 for unauthorized requests.
Also updates the docs on this feature to reflect this.
What does this PR try to resolve?
Artifactory likes to return 403 for unauthorized requests.
The meanings of HTTP
401 Unauthorized
and HTTP403 Forbidden
are very similar and largely overlapping.In order to make Cargo's
registry-auth
feature play better with 3rd-party registries, I would recommend also supporting attempting authentication for 403s even if that is not the perfectly semantic meaning.How should we test and review this PR?
Ideally, talk to a 3rd-party registry such as artifactory with this change included and all the config set on the 3rd party registry.
Additional information
Related tracking issue for the whole
registry-auth
feature: #10474